<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

</h:head>
<body>
	<h:form id="frmCadAliquota">
		<br  />
		<h3 style="margin-top: 0">CADASTRO DE ALÍQUOTA</h3>
		<div id="divGeral" align="left">
			<p:commandButton value="Novo" actionListener="#{aliquotaBean.novo}"
				ajax="grid" />
			<p:commandButton value="Salvar" disabled="#{aliquotaBean.sal}"
				actionListener="#{aliquotaBean.salvar}" ajax="grid" />

			<p:commandButton value="Alterar" disabled="#{aliquotaBean.alt}"
				actionListener="#{aliquotaBean.alterar}" ajax="grid" />

			<p:commandButton value="Excluir" process="@this" disabled="#{aliquotaBean.rem}"
				action="#{aliquotaBean.remover()}" update="frmCadAliquota" >
					<p:confirm icon="ui-icon-alert" header="Confirmação de exclusão" 
							message="Tem certeza que deseja excluir a alíquota?" />
			</p:commandButton>
				
			<p:commandButton id="consulta" value="Consulta"
				action="#{pesquisaAliquotaBean.abrirDialogo}">
				<p:ajax event="dialogReturn" listener="#{aliquotaBean.aliquotaSelecionado}" update="frmCadAliquota"/>
			</p:commandButton>

			<p:commandButton value="Cancelar"
				actionListener="#{aliquotaBean.cancelar}" ajax="grid" />
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<h:panelGrid id="grid" columns="2" columnClasses="label, value">
				
					Código da Alíquota:
					<p:inputText id="idAliq" disabled="true"
					value="#{aliquotaBean.aliquota.idAliq}" />
		
					Alíquota:
					<p:inputText id="aliq" value="#{aliquotaBean.aliquota.aliquota}"
					size="10" maxlength="5" disabled="#{aliquotaBean.aliq}" />
					
					Redução:
					<p:inputText id="red" value="#{aliquotaBean.aliquota.reducao}"
					size="40" disabled="#{aliquotaBean.red}" />

				<p:commandButton value="Vincular CST" type="button"
					disabled="#{aliquotaBean.vinculo}" onclick="PF('dlg4').show();" />

			</h:panelGrid>

			<p:dialog id="dialog1" header="Vincular CST" widgetVar="dlg4"
				modal="true" height="450" width="650">
				<h:panelGrid id="gridSelect" columns="1"
					columnClasses="label, value">
					Tipo CST:
					<p:selectOneMenu id="tipCst" value="#{aliquotaBean.tipCst}"
						style="width:200px;">
						<f:selectItem itemLabel="Selecione um Tipo de CST" />
						<f:selectItem itemLabel="Icms" itemValue="ICMS" />
						<f:selectItem itemLabel="Pis Cofins" itemValue="PISCOFINS" />
						<f:selectItem itemLabel="Ipi" itemValue="IPI" />
						<p:ajax update="gridCsts" event="change"
							listener="#{aliquotaBean.eventTipoCst}" />
					</p:selectOneMenu>
					<h:panelGrid id="gridCsts">
					
					Tipo Tributação Icms:
					<p:selectOneMenu id="trib" value="#{aliquotaBean.tipTrib}"
							style="width:250px;" disabled="#{aliquotaBean.tipTri}">
							<f:selectItem itemLabel="Selecione uma tributação" />
							<f:selectItem itemLabel="Substituicao" itemValue="SUBSTITUICAO" />
							<f:selectItem itemLabel="Tributado" itemValue="TRIBUTADO" />
							<f:selectItem itemLabel="Isento" itemValue="ISENTO" />
							<f:selectItem itemLabel="Não Tributado" itemValue="NTRIB" />
						</p:selectOneMenu>

					Cst Icms:
					<h:panelGrid columns="2">
						Ent/Sai:
						<p:selectOneMenu id="cstIcms" value="#{aliquotaBean.cst}"
								style="width:350px;" disabled="#{aliquotaBean.chkIcm}">
								<f:selectItem itemLabel="Selecione um CST de Icms" />
								<f:selectItems value="#{aliquotaBean.cstList}" var="cstIcmsList"
									itemValue="#{cstIcmsList}"
									itemLabel="#{cstIcmsList.cst} - #{cstIcmsList.descricao}" />
							</p:selectOneMenu>
						</h:panelGrid>
					CST Ipi:				
					<h:panelGrid columns="2">
						Entrada:
						<p:selectOneMenu id="cstIpiEnt" value="#{aliquotaBean.cstEnt}"
								style="width:350px;" disabled="#{aliquotaBean.chkIpi}">
								<f:selectItem itemLabel="Selecione um CST de Ipi para Entrada" />
								<f:selectItems value="#{aliquotaBean.cstListEnt}"
									var="listaCstIpiEnt" itemValue="#{listaCstIpiEnt}"
									itemLabel="#{listaCstIpiEnt.cst} - #{listaCstIpiEnt.descricao}" />
							</p:selectOneMenu>
						
						Saída:
						<p:selectOneMenu id="cstIpiSai" value="#{aliquotaBean.cstSai}"
								style="width:350px;" disabled="#{aliquotaBean.chkIpi}">
								<f:selectItem itemLabel="Selecione um CST de Ipi para Saída" />
								<f:selectItems value="#{aliquotaBean.cstListSai}"
									var="listaCstIpiSai" itemValue="#{listaCstIpiSai}"
									itemLabel="#{listaCstIpiSai.cst} - #{listaCstIpiSai.descricao}" />
							</p:selectOneMenu>
						</h:panelGrid>
					CST PisCofins:
						<p:selectOneRadio id="pisCofins"
							disabled="#{aliquotaBean.chkPisCofins}"
							value="#{aliquotaBean.aliquota.pisCofins}">
							<f:selectItem itemLabel="Pis" itemValue="PIS" />
							<f:selectItem itemLabel="Cofins" itemValue="COFINS" />
						</p:selectOneRadio>
						<h:panelGrid columns="2">

						Entrada:
							<p:selectOneMenu id="cstPisCofinsEnt"
								value="#{aliquotaBean.cstEnt}" style="width:350px;"
								disabled="#{aliquotaBean.chkPisCofins}">
								<f:selectItem
									itemLabel="Selecione um CST de PisCofisn para Entrada" />
								<f:selectItems value="#{aliquotaBean.cstListEnt}"
									var="listaCstPisCofinsEnt" itemValue="#{listaCstPisCofinsEnt}"
									itemLabel="#{listaCstPisCofinsEnt.cst} - #{listaCstPisCofinsEnt.descricao}" />
							</p:selectOneMenu>
						
						Saída:
							<p:selectOneMenu id="cstPisCofinsSai"
								value="#{aliquotaBean.cstSai}" style="width:350px;"
								disabled="#{aliquotaBean.chkPisCofins}">
								<f:selectItem
									itemLabel="Selecione um CST de PisCofins para Saída" />
								<f:selectItems value="#{aliquotaBean.cstListSai}"
									var="listaCstPisCofinsSai" itemValue="#{listaCstPisCofinsSai}"
									itemLabel="#{listaCstPisCofinsSai.cst} - #{listaCstPisCofinsSai.descricao}" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>
				</h:panelGrid>
				<p:commandButton value="OK" onclick="PF('dlg4').Hide();" />
			</p:dialog>
		</div>
	</h:form>
</body>
</html>
